const _import = require('./_import_production');

import Main from '../pages/main.vue'
import Login from '../pages/auth/Login.vue'
import Util from '../libs/util'
import Cookies from 'js-cookie'

export const loginRouter = {
  path: '/login',
  name: 'login',
  meta: {
    title: '登录'
  },
  beforeEnter: (to, from, next) => {
  if (Util.user())
    {
        next({
          name: 'all'
        })
    }
  else
  {
    next()
  }
},
component: Login
}

export const appRouter = [
  {
    path: '/home',
    component: Main,
    children: [
      {
        path: 'index',
        name: 'home_index',
        meta:
          {
            requireAuth: true,
            title: '首页',
            requirePermission:['admin']
          },
        component: _import('AllList')
      },
      {
        path: 'all-list/:school?',
        name: 'all',
        meta:
          {
            requireAuth: true,
            requirePermission:['admin','编辑']
          },
        component:  _import('AllList') //报名管理
      },
      {
        path: 'log-list',
        name: 'log',
        meta:
          {
            requireAuth: true,
            requirePermission:['admin']
          },
        component: _import('LogList') //日志
      },
      {
        path: 'user-manage',
        name: 'user-manage',
        meta:
          {
            requireAuth: true,
            requirePermission:['admin']
          },
        component: _import('UserManage') //用户管理
      },
      {
        path: 'enroll-situation',
        name: 'enroll-situation',
        meta:
          {
            requireAuth: true,
            requirePermission:['admin','编辑']
          },
        component:  _import('EnrollSituationList')//幼儿园管理
      },
      {
        path: 'see-situation',
        name: 'only-enroll-situation',
        meta:
          {
            requireAuth: true,
            requirePermission:['admin','录入']
          },
        component:  _import('EnrollSituationOnlySee') //报名情况
      },
      {
        path: 'student-enroll/:keyword?',
        name: 'student-enroll',
        meta:
          {
            requireAuth: true,
            requirePermission:['admin']
          },
        component:  _import('StudentEnrollList') //录取结果
      },
      {
        path: 'entering/:user_id?',
        name: 'entering',
        meta:
          {
            requireAuth: true,
            requirePermission:['admin','录入','编辑']
          },
        component: _import('Entering')
      },
      {
        path: 'print-out/:user_id',
        name: 'print',
        meta:
          {
            requireAuth: true,
            requirePermission:['admin','录入','编辑']
          },
        component: _import('PrintOut')
      }
    ]
  }]

export const routers = [
    loginRouter,
    ...appRouter
  ]

